/**
 * 
 */
package com.gragra.applications;
import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
/**
 * @author Christoph Teichmann
 * 21.08.2013
 */
public class AverageAndVariance
{
	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new FileReader(args[0]));
		String line = br.readLine();
		String[] parts = line.split("\\s+");
		DoubleArrayList[] list = new DoubleArrayList[parts.length];
		for(int i=0;i<parts.length;++i)
		{list[i] = new DoubleArrayList();}
		while((line = br.readLine()) != null)
		{
			double[] ents = makeEnts(line);
			for(int i=0;i<ents.length;++i)
			{
				list[i].add(ents[i]);
			}
		}
		double[] means = new double[parts.length];
		double[] variances = new double[parts.length];
		for(int i=0;i<list.length;++i)
		{
			means[i] = makeMean(list[i]);
			variances[i] = makeVariance(list[i],means[i]);
		}
		System.out.println(Arrays.toString(parts));
		System.out.println(Arrays.toString(means));
		System.out.println(Arrays.toString(variances));
		br.close();
	}
	/**
	 * 
	 * @param doubleArrayList
	 * @param d
	 * @return
	 */
	private static double makeVariance(DoubleArrayList doubleArrayList, double d)
	{
		DoubleIterator di = doubleArrayList.iterator();
		double ret = 0.0;
		while(di.hasNext())
		{ret = Math.pow(di.nextDouble()-d, 2.0);}
		ret /= doubleArrayList.size();
		return ret;
	}
	/**
	 * 
	 * @param doubleArrayList
	 * @return
	 */
	private static double makeMean(DoubleArrayList doubleArrayList)
	{
		DoubleIterator di = doubleArrayList.iterator();
		double ret = 0.0;
		while(di.hasNext())
		{ret += di.nextDouble();}
		ret /= doubleArrayList.size();
		return ret;
	}
	/**
	 * 
	 * @param line
	 * @return
	 */
	private static double[] makeEnts(String line)
	{
		String[] parts = line.split("\\s+");
		double[] ret = new double[parts.length];
		for(int i=0;i<parts.length;++i)
		{ret[i] = Double.parseDouble(parts[i]);}
		return ret;
	}
}